<template>
    <div class="home-box">
        <div class="home-title">激光清障仪管控平台</div>

        <div class="register-box">
            <div class="demo-input-suffix">
                <el-input placeholder="请输入内容" v-model="register.name">
                    <i slot="prefix" class="el-input__icon el-icon-search title-icon"></i>
                </el-input>
                <el-input placeholder="请输入密码" v-model="register.password" show-password>
                    <i slot="prefix" class="el-input__icon el-icon-search title-icon1"></i>
                </el-input>
            </div>
            <div class="submit-register click-pointer" @click="clickRegister">登录</div>
        </div>
    </div>
</template>

<script>
import {login} from '@/utils/api.js';
export default {
    name: 'myRegister',
    components: {},
    data() {
        return {
            register: {
                name: '',
                password: '',
            },
        };
    },
    methods: {
        clickRegister() {
            login(this.register)
                .then(res => {
                    const token = res.data.user_key;
                    this.$cookie.set('token', token);
                    this.$router.push('/unitMap');
                    localStorage.setItem('userDetails', JSON.stringify(res.data)); //登录时候存入用户信息
                })
                .catch(err => {
                    console.log(err, '请求失败');
                    this.$message.error('账号密码错误');
                });
        },
    },
};
</script>

<style scoped>
/* 组件样式 */
.register-box {
    width: 440px;
    background-image: url('@/assets/img/register.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    margin: 0 auto;
    transform: translateY(150px);
    padding: 60px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.title-icon {
    background-image: url('@/assets/img/left-iocn.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    width: 25px;
    height: 25px;
}

.title-icon1 {
    background-image: url('@/assets/img/left-iocn1.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    width: 25px;
    height: 25px;
}

.register-box >>> .el-input__prefix {
    display: flex;
    align-items: center;
}

.el-icon-search:before {
    content: '\e778';
    display: none;
}

.register-box >>> .el-input {
    /* background-image: url('@/assets/img/left-iocn.png'); */
    border-bottom: 1px solid #fff;
    margin-top: 20px;
}

.demo-input-suffix {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 280px;
}

.register-box >>> .el-input__inner {
    background: none;
    border: none;
    line-height: 50px;
    height: 50px;
}

.register-box >>> .el-input--prefix .el-input__inner {
    padding-left: 40px;
}

.submit-register {
    background-image: url('@/assets/img/submit-register.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    font-weight: 400;
    font-size: 25px;
    color: #ebf4ff;
    line-height: 50px;
    width: 370px;
    text-align: center;
    margin-top: 50px;
}

.register-box >>> .el-input__inner {
    color: #03bccf;
    font-size: 16px;
}
</style>
